/* eslint-disable react/button-has-type */
import React, { createContext, useState, Fragment } from 'react';
import { Button } from 'antd';
import { Context } from './components/context';
import { ContextFun } from './components/contextFun';

export const CountContext = createContext();

const UserContextConponent = () => {
    const [count, setCount] = useState(0);
    const addCount = () => {
        setCount(count + 1);
    };

    return (
        <Fragment>
            <p>count: {count}</p>
            <Button onClick={addCount}>count + 1</Button>
            <CountContext.Provider value={{ count, type: 'useContext' }}>
                <Context />
            </CountContext.Provider>
            <ContextFun count={count} type="ContextFun" />
        </Fragment>
    );
};

export default UserContextConponent;
